#pragma once

template<class Iterator, class Ref, class Ptr>
struct __reverse_iterator
{
	typedef __reverse_iterator<Iterator, Ref, Ptr> self;

	Iterator _cur;

	__reverse_iterator(Iterator cur)
		:_cur(cur)
	{}

	Ref operator*()
	{
		Iterator tmp = _cur;
		return *--tmp;
	}

	Ptr operator->()
	{
		return &(operator*());
	}

	self& operator++()
	{
		--_cur;
		return *this;
	}

	self operator++(int)
	{
		Iterator tmp = _cur;
		--_cur;
		return tmp;
	}

	self& operator--()
	{
		++_cur;
		return *this;
	}

	self operator--(int)
	{
		Iterator tmp = _cur;
		++_cur;
		return tmp;
	}

	bool operator==(const self& s)
	{
		return _cur == s._cur;
	}

	bool operator!=(const self& s)
	{
		return _cur != s._cur;
	}
};
